<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
	.table_box {
	}
	.exportBtn{
		background:#339900;
		padding:3px 5px;
		color:#FFFFFF;
		border:0px;
		border-radius:4px;
		float:right;
		cursor:pointer;
		margin-right:20px;
	}
</style>
</head>

<body>
	<div class="page_header">
	<div class="table_tool">
		<ul class="clearfix">			
			<li class="memberDel btn"><i class="icon-remove"></i> 批量删除</li>
		</ul>
	</div>
	<form name="searchForm" id="searchForm" method="post" action="{:U('Outlet/export')}">
	<div class="search_box">
		<select name="outletid" id="outletid" class="form_ele w200">
			<option value="">请选择餐厅</option>
			<volist name="mesList" id="v">
				<option value="{$v.id}">{$v.title}</option>
			</volist>
		</select>
		关键字：<input type="text" id="keywords" class="form_ele w100">
		<span id="doSearch" class="doSearch">
			<i class="icon-search"></i> 搜索
		</span>
	</div>
	</form>
	
	</div>
	<div class="table_box">
	</div>
</body>
<script type="text/javascript">
	var listConfig = {
			gridId : 'memberList',
			blockBox : '.table_box',
			blockBoxHeight : 'window',
			jsonUrl : '__URL__/message',
			where : '',
	 		getWhere : function(){
	 			var where         = {};
				where['keywords'] = $('#keywords').val();
				where['restid']   = $('#outletid').val();
				return where;
			},
			
			widthType : 'tdw', //thw-标题标准宽度、tdw-数据单元标准宽度、auto-随数据单元宽度
			pageNum : 10,
			nowPage : 1,
			orderName : "addtime",
			orderDirection : "desc",
			dataContextMenuOpen: true, //是否开启数据行右键菜单
			dataContextMenu: function(){
				$.contextMenu({
					selector: '.et_tbody tr',
					items: {
						"delete": {
							name: "删除", 
							icon: "edit",
							callback: function(key, options) {
								
								var val = $(this).attr('rowid');
								var msg = "确认要删除该留言吗？";
								
								windowApi.lhgdialog.confirm(msg, function(){
									$.post("{:U('Outlet/messageDel')}",{val:val},function(data){
										if(data.status==1){
											$('.et_tfoot .page_refresh').click(); //刷新加载
										}else{
											windowApi.lhgdialog.alert(data.info,function(){return;});
										}
									});
								},function(){
									return;
								});
							}
						}
					}
				});
			},
			colModel : [
				{
					display : 'checkbox',
					name : 'id',
					sortable : false,
					myclass : 'center',
					edit : false
				},
				{
					display : '邮箱',
					name : 'email',
					sortable : true,
					myclass : 'center',
					edit : true
				},
				{
					display : '手机号码',
					name : 'mobile',
					sortable : true,
					myclass : 'center',
					edit : true,
					width:'80px'
				},
				{
					display : '留言内容',
					name : 'content',
					sortable : true,
					myclass : 'center',
					edit : false,
				},
				{
					display : '用户类型',
					name : 'tableid',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'80px'
				},
				{
					display : '添加时间',
					name : 'addtime',
					sortable : true,
					myclass : 'center',
					edit : false,
					width:'95px'
				},
			]
		};
	
	//实例化列表
	var tableList = $('.table_box').EtGrid(listConfig);
	//tableList.erefresh();
	
	//搜索
 	$('#doSearch').on('click',function(){
		
		var where = tableList.config.getWhere();
		
		tableList.config.where = where;
		tableList.search();
	});
	
 	$(".exportBtn").on('click',function(){
		$("#searchForm").submit();
	})
	
	//批量删除
	$('.memberDel').on('click',function(){
		
		var val = tableList.getChecked();
		var msg = "确认要将选中的留言删除吗？";
		
		if(val){
			windowApi.lhgdialog.confirm(msg, function(){
				$.post("{:U('Outlet/messageDelall')}",{val:val},function(data){
					if(data.status==1){
						$('.et_tfoot .page_refresh').click(); //刷新加载
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){
				return;
			});
		}else{
			windowApi.lhgdialog.alert('请选择需要删除的留言！');
		}
	});
</script>
</html>
